<?php

namespace App\Winged\Tenants;

use App\Winged\Tenants\Redis\Keys;

class TenantRedis extends AbstractTenant
{
    public function getConfig($tenant) : array
    {
        if(isset($this->config[$tenant])){
            return $this->config [$tenant];
        }
        return $this->config[$tenant] = Keys::getConfig($tenant);
    }

    public function setProtype($config)
    {
        foreach ($config as $key => $val){
            if(empty($val)){
                    $val = null ;
            }
            $this->{$key} = $val ;
        }
    }

    public function getService()
    {
        if(is_array($this->services)){
            return $this->services ;
        }
        return $this->services = json_decode($this->services,true);
    }

    public function getRedirect()
    {
        return is_null($this->admin_default_url) ? '/admin' : $this->admin_default_url ;
    }
}
